package com.yitongmao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yitongmao.bean.HomeListBean;
import com.yitongmao.yitmfruit.R;

import java.util.List;

/*
* 作者：梁伟航 on 2017/7/12 17:55
* 类的用途：
*/
public class mHomeGridViewredaishuiguoAdapter extends BaseAdapter{
    private Context context;
    //String[] arrayName = new String[]{"山东大苹果", "台湾凤梨", "巴西牛油果", "宝石红提", "东南亚蜜桔", "西北樱桃"};
    //int[] images = new int[]{ R.drawable.shandongdapingguo, R.drawable.taiwanfengli,  R.drawable.baxiniuyouguo, R.drawable.xibeihongti,R.drawable.baoshihongti, R.drawable.huolongguo};
   // String[] array = new String[]{"￥10.8/kg", "￥10.8/kg", "￥10.8/kg", "￥10.8/kg", "￥10.8/kg", "￥10.8/kg"};
    private List<HomeListBean.SeasonalListBean> seasonalList;

    public mHomeGridViewredaishuiguoAdapter(Context context, List<HomeListBean.SeasonalListBean> seasonalList) {
        this.context=context;
        this.seasonalList=seasonalList;
    }
    @Override
    public int getCount() {
        return seasonalList.size();
    }

    @Override
    public Object getItem(int position) {
        return seasonalList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context, R.layout.mhomegridviewredaishuiguoitem, null);
            viewHolder.mMyGridViewTextViewTitle = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewTitle);
            viewHolder.mMyGridViewTextViewBody = (TextView) convertView.findViewById(R.id.mMyGridViewTextViewBody);
            viewHolder.mMyGridViewImage= (ImageView) convertView.findViewById(R.id.mMyGridViewImage);
            convertView.setTag(viewHolder);//绑定ViewHolder对象
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mMyGridViewTextViewTitle.setText(seasonalList.get(position).title);
        viewHolder.mMyGridViewTextViewBody.setText(seasonalList.get(position).retailPrice+"/Kg");
        Glide.with(context).load(seasonalList.get(position).thumb).into(viewHolder.mMyGridViewImage);
        return convertView;
    }
    class ViewHolder {
        public TextView mMyGridViewTextViewTitle;
        public TextView mMyGridViewTextViewBody;
        public ImageView mMyGridViewImage;
    }
}
